home *** CD-ROM | disk | FTP | other *** search
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.Vector;
-
- public class FriendsServer {
- Socket socket;
- // $FF: renamed from: ss java.net.ServerSocket
- ServerSocket field_0;
- Vector thread;
- int priority = 2;
- String prefix = "***";
- boolean debug = false;
- String topic;
- String topicAuthor;
-
- public static void main(String[] var0) {
- int var1 = 0;
- if (var0.length != 0) {
- try {
- var1 = Integer.parseInt(var0[0]);
- } catch (Exception var2) {
- var1 = 5554;
- }
- } else {
- var1 = 5554;
- }
-
- new FriendsServer(var1);
- }
-
- FriendsServer(int var1) {
- try {
- this.field_0 = new ServerSocket(var1);
- } catch (Exception var3) {
- System.out.println(var3);
- }
-
- this.init();
- }
-
- public void init() {
- this.thread = new Vector();
-
- try {
- while(true) {
- if (this.debug) {
- System.out.println("socket waiting...");
- }
-
- this.socket = this.field_0.accept();
- if (this.debug) {
- System.out.println("accept a connectionon port " + Integer.toString(5554));
- }
-
- int var1 = this.thread.size();
- FriendsServer$RecThread var2 = new FriendsServer$RecThread(this, this.socket, var1, this);
- ((Thread)var2).setPriority(this.priority);
- ((Thread)var2).start();
- this.thread.addElement(var2);
- }
- } catch (Exception var3) {
- System.out.println(var3);
- }
- }
-
- public void sendAll(int var1, String var2) {
- for(int var3 = 0; var3 < this.thread.size(); ++var3) {
- if (var3 != var1) {
- ((FriendsServer$RecThread)this.thread.elementAt(var3)).send(var2);
- }
- }
-
- }
-
- public void sendAll(String var1) {
- for(int var2 = 0; var2 < this.thread.size(); ++var2) {
- ((FriendsServer$RecThread)this.thread.elementAt(var2)).send(var1);
- }
-
- }
-
- public void sendOne(int var1, String var2) {
- ((FriendsServer$RecThread)this.thread.elementAt(var1)).send(var2);
- }
-
- public int giveId(String var1) {
- for(int var2 = 0; var2 < this.thread.size(); ++var2) {
- if (((FriendsServer$RecThread)this.thread.elementAt(var2)).nick.equals(var1)) {
- return var2;
- }
- }
-
- return -1;
- }
-
- public void stop(int var1, int var2) {
- if (this.debug) {
- System.out.println("thread " + Integer.toString(var1) + " libere");
- }
-
- FriendsServer$RecThread var3 = (FriendsServer$RecThread)this.thread.elementAt(var1);
- if (var3.is_nick) {
- if (var2 == 0) {
- this.sendAll(var1, var3.nick + " PART @ " + var3.arg[3] + "\n");
- } else {
- this.sendAll(var1, var3.nick + " PART @ " + "crash !" + "\n");
- }
- }
-
- this.thread.removeElementAt(var1);
- if (var3 != null) {
- ((Thread)var3).stop();
- }
-
- }
-
- public boolean isNick(String var1) {
- for(int var2 = 0; var2 < this.thread.size(); ++var2) {
- if (((FriendsServer$RecThread)this.thread.elementAt(var2)).nick.equals(var1)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String giveNicks() {
- String var1 = new String();
-
- for(int var2 = 0; var2 < this.thread.size(); ++var2) {
- var1 = var1 + " " + ((FriendsServer$RecThread)this.thread.elementAt(var2)).nick;
- }
-
- return var1.trim();
- }
- }
-